/**
 * Tencent is pleased to support the open source community by making Tseer available.
 *
 * Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
 * 
 * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * https://opensource.org/licenses/BSD-3-Clause
 *
 * Unless required by applicable law or agreed to in writing, software distributed 
 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */

// **********************************************************************
// This file was generated by a TARS parser!
// TARS version 1.0.1.
// **********************************************************************

package com.qq.cloud.router.client.share.tseer;

import com.qq.tars.protocol.util.*;
import com.qq.tars.protocol.annotation.*;
import com.qq.tars.protocol.tars.*;
import com.qq.tars.protocol.tars.annotation.*;

@TarsStruct
public class RouterNodeInfo {

	@TarsStructProperty(order = 1, isRequire = false)
	public String ip = "";
	@TarsStructProperty(order = 2, isRequire = false)
	public int port = 0;
	@TarsStructProperty(order = 3, isRequire = false)
	public boolean isTcp = false;
	@TarsStructProperty(order = 4, isRequire = false)
	public int weight = 0;
	@TarsStructProperty(order = 5, isRequire = false)
	public String setname = "";

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public boolean isTcp() {
		return isTcp;
	}

	public void setTcp(boolean isTcp) {
		this.isTcp = isTcp;
	}

	public int getWeight() {
		return weight;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}

	public String getSetname() {
		return setname;
	}

	public void setSetname(String setname) {
		this.setname = setname;
	}

	public RouterNodeInfo() {
	}

	public RouterNodeInfo(String ip, int port, boolean isTcp, int weight, String setname) {
		this.ip = ip;
		this.port = port;
		this.isTcp = isTcp;
		this.weight = weight;
		this.setname = setname;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + TarsUtil.hashCode(ip);
		result = prime * result + TarsUtil.hashCode(port);
		result = prime * result + TarsUtil.hashCode(isTcp);
		result = prime * result + TarsUtil.hashCode(weight);
		result = prime * result + TarsUtil.hashCode(setname);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof RouterNodeInfo)) {
			return false;
		}
		RouterNodeInfo other = (RouterNodeInfo) obj;
		return (
			TarsUtil.equals(ip, other.ip) &&
			TarsUtil.equals(port, other.port) &&
			TarsUtil.equals(isTcp, other.isTcp) &&
			TarsUtil.equals(weight, other.weight) &&
			TarsUtil.equals(setname, other.setname) 
		);
	}

	public void writeTo(TarsOutputStream _os) {
		if (null != ip) {
			_os.write(ip, 1);
		}
		_os.write(port, 2);
		_os.write(isTcp, 3);
		_os.write(weight, 4);
		if (null != setname) {
			_os.write(setname, 5);
		}
	}

	public void readFrom(TarsInputStream _is) {
		this.ip = _is.read(ip, 1, false);
		this.port = _is.read(port, 2, false);
		this.isTcp = _is.read(isTcp, 3, false);
		this.weight = _is.read(weight, 4, false);
		this.setname = _is.read(setname, 5, false);
	}

}
